<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS aspect ratio</title>

    <style>
      * {
        margin: 0;
        padding: 0;
        font-family: sans-serif;
        box-sizing: border-box;
      }

      body {
        background: hsl(0deg, 0%, 8%);
      }

      main {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        display: grid;
        place-items: center;
      }

      .imageContainer {
        width: 500px;
        height: 500px;
        resize: both;
        overflow: auto;

        /* aspect-ratio: 16 / 9; */

        border: 4px solid hsl(140deg, 100%, 70%);
      }

      img {
        max-width: 100%;
        max-height: 100%;
        /* 不加就是原始纵横比 */
        /* aspect-ratio: 1 / 1; */
      }
    </style>
  </head>
  <body>
    <main>
      <div class="imageContainer">
        <img src="./2021-12-20-20-29-28.png" alt="" />
      </div>
    </main>
  </body>
</html>
